package org.lojzes.minstruts.listener;

import java.util.Map;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.lojzes.minstruts.xml.XMLBean;
import org.lojzes.minstruts.xml.XMLParse;

public class ServletListener implements ServletContextListener {
	protected static Log log = LogFactory.getLog(ServletListener.class);
	@Override
	public void contextDestroyed(ServletContextEvent contextEvent) {
		log.info("===>>用户注销！");
	}

	@Override
	public void contextInitialized(ServletContextEvent contextEvent) {
		String tomcatPath = contextEvent.getServletContext().getRealPath("\\");
		String configPath = contextEvent.getServletContext().getInitParameter("config-path");
		Map<String, XMLBean> xmlBeanMap = XMLParse.parse(tomcatPath+configPath);
		contextEvent.getServletContext().setAttribute("xmlBeanMap", xmlBeanMap);
	}
}
